/*
 * @Date: 2020-08-27 10:53:36
 */
import React, { Component } from 'react'
import { connect } from 'react-redux';

class ReactRedux extends Component {
  render() {
    const { num, add } = this.props;
    return (
      <div>
        {num}
        <button onClick={add}>改变数据</button>
      </div>
    )
  }
}
// 数据
const mapStateToProps = state => {
  return {
    num: state
  }
}
// 派发事件
const mapDispatchToProps = {
  add: () => ({
    type: 'ADD'
  })
}
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(ReactRedux)

